import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import { User } from '../user/user.entity';

@Entity('address') // 数据库表名
export class Address {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  userId: number;

  @Column()
  province: string;

  @Column()
  city: string;

  @Column()
  area: string;

  @Column()
  detailed: string;

  @ManyToOne(() => User)
  @JoinColumn({ name: 'userId' })
  user: User; // 关联用户实体

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;
}